age = 3
if age >= 18:
    print('adult')
elif age >= 6:
    print('teenager')
else:
    print('kid')
#此外input返回的数据是str类型,可以用int()来转换为int类型
s = input('birth: ')
birth = int(s)
if birth < 2000:
    print('00前')
else:
    print('00后')
#python与js不同一点<,>可以连写
bmi = 80.5/1.75**2
if bmi<18.5:
    print("过轻")
elif 18.5<bmi<25:
    print("正常")
elif 25<bmi<28:
    print("过重")
elif 28<bmi<32:
    print("肥胖")
else:
    print("严重肥胖")
#除了if-elif-else还有match如同java和js的switch
age =100

match age:
    case x if x < 10:#x<10的时候赋值给x
        print(f'< 10 years old: {x}')#f-string来占位
    case 10:
        print('10 years old.')
    case 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18:
        print('11~18 years old.')
    case 19:
        print('19 years old.')
    case _:
        print('not sure.')

 #match匹配list       
args = ['gcc', 'hello.c', 'world.c']
# args = ['clean']
# args = ['gcc']

match args:
    # 如果仅出现gcc，报错:
    case ['gcc']:
        print('gcc: missing source file(s).')
    # 出现gcc，且至少指定了一个文件:
    case ['gcc', file1, *files]:
        print( file1 + ', ' + ', '.join(files))
    # 仅出现clean:
    case ['clean']:
        print('clean')
    case _:
        print('invalid command.')

#python循环遍历一个list
names = ['Michael', 'Bob', 'Tracy']
for name in names:
    print(name)
#利用 range(101)方法返回一个0~100的有序数列
sum = 0
for x in range(101):
    sum = sum + x
print(sum)
#while循环 break语句可以跳循环,continue可以跳出这次循环直接开始下一次循环
#不要滥用break和continue语句
L = ['Bart', 'Lisa', 'Adam']
n = 0
while n < len(L):
    print(L[n])
    n=n+1
